Repository navigation
feat(moshi): add local Moshi speech-to-speech adapter - #52
Merged
Merged
Conversation
Socket.run/7 takes a decoder that maps each text or binary frame to a handler event. The default still accepts JSON objects only, so the OpenAI Realtime and Gemini Live adapters do not change.
AudioFlow.Adapters.Moshi runs one committed 24 kHz turn against a local Kyutai Moshi server (moshi_mlx.local_web) for Session speech_to_speech. Ogg Opus framing and coding use membrane_ogg_plugin and membrane_opus_plugin. The adapter sends one Ogg page per 80 ms frame, paces silence by received output, drops output for the input period and ends the reply after a silence without text tokens.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
AudioFlow.Adapters.Moshi, a Sessionspeech_to_speechadapter for a local Kyutai Moshi server. It is the smallest local open speech-to-speech model: 7B, 4-bit MLX, approximately 5 GB of weights. It runs on an Apple Silicon laptop.membrane_opus_plugin. Ogg pages usemembrane_ogg_plugin(Page,Parser,Opusheaders). There is no custom codec or container code.0handshake,1Ogg Opus 24 kHz,2text). The adapter sends one Ogg page for each 80 ms frame.Membrane.Ogg.Muxerholds packets until a page has 255 segments (approximately 5 s), so the adapter builds pages directly.:end_silence_ms(1,600) without text, or fails with:no_replyafter:max_reply_ms(20,000).Providers.Socket.run/7accepts a frame decoder. The default is the old JSON decoder, so OpenAI Realtime and Gemini Live do not change.Limits
Nativeand OggPage/Parsermodules are internal to the plugins. The versions are pinned (~> 0.21.0,~> 0.5.2).:transcriptevent).Verification
AUDIOFLOW_MEDIA=1 mix test: 238 passed. Coremix test: 215 passed.credo --strict,dialyzer,mix format,rumdl: clean.moshi_mlx.local_web(-q 4, M5, 24 GB):AUDIOFLOW_MEDIA=1 AUDIOFLOW_HTTP_MODEL_TESTS=1 AUDIOFLOW_MOSHI_PCM=question.s16le mix test test/moshi_test.exspassed. Session turns gave correct spoken answers. The first reply audio came 2.1–3.0 s after submit for a 3.2 s question. The first turn after server start took approximately 13 s (MLX warm-up).TMPDIRis a symlinked/var/folders/...path, 15 recording tests fail with:unsafe_path. This is not related to this change. They pass with a non-symlinkedTMPDIR.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.